﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/TwoColumn.Master" AutoEventWireup="true"
    CodeBehind="ShoppingCartView.aspx.cs" Inherits="TelerikStore.ShoppingCartView" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="ShoppingCartGrid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ShoppingCartGrid" LoadingPanelID="LoadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>
    <telerik:RadAjaxLoadingPanel ID="LoadingPanel" runat="server" Skin="Default" />
    <div id="product-category">
        <h2>
            Your Shopping Cart
        </h2>
        <div id="search-form">
            <telerik:RadTextBox ID="SearchBox" runat="server" EmptyMessage="Search an item..." AutoPostBack="true" OnTextChanged="PerformSearch">
                <ClientEvents OnKeyPress="searchBoxKeyPress" />
            </telerik:RadTextBox>
            <telerik:RadButton ID="SearchButton" runat="server" Text="Search" AutoPostBack="true"
                OnClick="PerformSearch" OnClientClicking="searchButtonClicking" />
            <br />
            <span id="SearchError">
                <!-- -->
            </span>
        </div>
    </div>
    <asp:Panel ID="ShoppingCartPanel" runat="server" CssClass="shopping-cart-pannel">
        <telerik:RadGrid ID="ShoppingCartGrid" runat="server" OnNeedDataSource="ShoppingCartGrid_NeedDataSource">
            <MasterTableView ShowFooter="true" AutoGenerateColumns="false" DataKeyNames="Id">
                <Columns>
                    <telerik:GridImageColumn HeaderText="IMAGE" DataImageUrlFields="SmallPicture" UniqueName="Image"
                        ImageWidth="64px" ImageHeight="64px" />
                    <telerik:GridBoundColumn HeaderText="PRODUCT" DataField="Title" UniqueName="Product" />
                    <telerik:GridTemplateColumn HeaderText="ITEMS" DataField="Quantity" UniqueName="Items">
                        <ItemTemplate>
                            <telerik:RadNumericTextBox ID="ItemQuantityTextBox" DbValue='<%# Eval("Quantity") %>'
                                runat="server" AutoPostBack="true" ShowButton="true" OnTextChanged="ItemQuantityTextBox_TextChanged">
                                <NumberFormat DecimalDigits="0" />
                            </telerik:RadNumericTextBox>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn HeaderText="PRICE" DataField="Price" UniqueName="Price"
                        DataType="System.Double" DataFormatString="${0:0.00}" FooterText="TOTAL:">
                    </telerik:GridBoundColumn>
                    <telerik:GridCalculatedColumn HeaderText="TOTAL" DataFields="Price,Quantity" UniqueName="TotalPrice"
                        DataType="System.Double" Aggregate="Sum" Expression="{0}*{1}" DataFormatString="${0:0.00}"
                        FooterAggregateFormatString="${0:0.00}">
                    </telerik:GridCalculatedColumn>
                </Columns>
                <FooterStyle Font-Size="12" Height="25" />
            </MasterTableView>
        </telerik:RadGrid>
        <div class="buttons">
            <telerik:RadButton ID="EmptyCartButton" runat="server" Text="Empty Cart" Width="100px"
                Height="34px" ButtonType="LinkButton" CssClass="empty-cart" OnClick="EmptyCartButton_Click">
                <Icon PrimaryIconUrl="~/common/icons/close.png" PrimaryIconTop="13px" PrimaryIconLeft="12px" />
            </telerik:RadButton>
            <telerik:RadButton ID="BuyCartButton" runat="server" Text="Buy" Width="80px" Height="34px"
                ButtonType="LinkButton" CssClass="buy-cart" OnClick="BuyButton_Click">
                <Icon PrimaryIconUrl="~/common/icons/arrowRight.png" PrimaryIconTop="13px" PrimaryIconLeft="12px" />
            </telerik:RadButton>
        </div>
    </asp:Panel>
      <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">

            function searchButtonClicking(sender, args)
            {
                var textBox = $find("<%=SearchBox.ClientID %>")

                if (textBox.get_value() == "") 
                {
                    args.set_cancel(true);
                }
            }

            function searchBoxKeyPress(sender, args) {

                var code = args.get_keyCode();
                if (code == 13 && sender.get_textBoxValue() == "") {
                    args.set_cancel(true);
                }
            }         
        </script>
    </telerik:RadScriptBlock>
</asp:Content>
<asp:Content ID="LeftContent" ContentPlaceHolderID="LeftSideContent" runat="server">
</asp:Content>
